package com.eckey.lab.common;

import com.eckey.lab.enums.ExceptionEnum;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.Serializable;

/**
 * @Author: Marinc
 * @CreateTime: 2024-06-17  14:20
 * @Description: TODO
 * @Version: 1.0
 */
@Data
@AllArgsConstructor
public class ResultData<T> implements Serializable {


    public ResultData(String code,String msg) {
        this.code=code;
        this.msg = msg;
    }


    private String code;

    private String msg;

    private T data;


    public static <T> ResultData success() {
        return new ResultData(ExceptionEnum.SUCCESS.getCode(), ExceptionEnum.SUCCESS.getErrorMsg(), null);
    }


    public static ResultData fail() {
        return new ResultData(ExceptionEnum.SUCCESS.getCode(), ExceptionEnum.SUCCESS.getErrorMsg(), null);
    }

    public static <T> ResultData success(T data) {
        return new ResultData(ExceptionEnum.SUCCESS.getCode(), ExceptionEnum.SUCCESS.getErrorMsg(), data);
    }
}
